{extend name="public/base" /}
{block name="title"}留言列表{/block}

{block name="content"}
<div class="container">
    <div class="row">
        <div class="col-md-12">
            <div class="panel-body" style="padding: 15px 0;">
                <ul class="nav nav-tabs">
                    <li class="active"><a href="">留言列表</a></li>
                </ul>
            </div>
            <?php if($list){ ?>
            <div class="panel panel-default">
                <div class="table-responsive">
                    <table class="table table-bordered">
                        <thead>
                            <tr>
                                <th class="w5p">ID</th>
                                <th>内容</th>
                                <th class="w15p">时间</th>
                                <th class="w10p">姓名</th>
                                <th class="w12p">电话</th>
                                <th class="w10p">操作</th>
                            </tr>
                        </thead>
                        <tbody>
                        <?php foreach($list as $row){ ?>
                            <tr>
                                <td class="center" style="vertical-align: middle;"><?php echo $row["id"]; ?></td>
                                <td class="center" style="vertical-align: middle;"><?php echo $row["msg"]; ?></td>
                                <td class="center" style="vertical-align: middle;"><?php echo date('Y-m-d H:i:s',$row["add_time"]); ?></td>
                                <td class="center" style="vertical-align: middle;"><?php echo $row["name"]; ?></td>
                                <td class="center" style="vertical-align: middle;"><?php echo $row["mobile"]; ?></td>
                                <td class="center" style="vertical-align: middle;">
                                    <a data-url="{:url('shop/Guestbook/del')}?id=<?php echo $row["id"]; ?>" data-toggle="modal" data-target="#delConfirmModal" href="javascript:;"><i class="glyphicon glyphicon-remove"></i> 删除</a>
                                </td>
                            </tr>
                        <?php } ?>
                        </tbody>
                    </table>
                </div>
                <div class="panel-footer">
                    <?php if($page){echo $page;}else{echo '共'.$list->total().'条';} ?>
                </div>
            </div>
            <?php }else{ ?>
            <div class="center" style="padding-top:25px;padding-bottom:25px;color:#666;">
                <p><i class="glyphicon glyphicon-send" style="font-size:36px;"></i></p>
                <h4>暂无记录</h4>
            </div>
            <?php } ?>
        </div>
    </div>
</div>

<!-- 删除模态框Modal -->
<div class="modal fade bs-example-modal-sm" id="delConfirmModal" tabindex="-1" role="dialog" aria-labelledby="myModalLabel">
    <div class="modal-dialog modal-sm" role="document">
        <div class="modal-content">
            <div class="modal-header">
                <button type="button" class="close" data-dismiss="modal" aria-label="Close"><span aria-hidden="true">&times;</span></button>
                <h4 class="modal-title" id="myModalLabel">信息</h4>
            </div>
            <div class="modal-body">确定删除吗？<br><br><input id="del-url" style="display:none;" type="text" value=""></div>
            <div class="modal-footer">
                <button type="button" class="btn btn-default" data-dismiss="modal">取消</button>
                <button type="button" class="btn btn-success" onclick="javascript:window.location.href = $('#del-url').val();">确定</button>
            </div>
        </div>
    </div>
</div>
<script>
$(function() {
    // 绑定模态框展示的方法  
    $("#delConfirmModal").on("show.bs.modal",function(e){
        // 获得点击打开的按钮
        var button=$(e.relatedTarget);
        // 根据标签获得按钮传入的参数
        var recipient=button.data("url");
        // 获得模态框本身
        var modal=$(this);
        // 更改将title的text  
        //modal.find(".modal-title").text("Hello"+recipient);
        // 更改body里input的值
        modal.find("#del-url").val(recipient);
    });
});
</script>
{/block}